package com.ruoyi.project.business.controller;

import java.util.List;

import com.ruoyi.project.business.domain.TgxsUserSuggest;
import com.ruoyi.project.business.service.ITgxsUserSuggestService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 意见反馈Controller
 * 
 * @author ruoyi
 * @date 2020-11-06
 */
@RestController
@RequestMapping("/system/suggest")
public class TgxsUserSuggestController extends BaseController
{
    @Autowired
    private ITgxsUserSuggestService tgxsUserSuggestService;

    /**
     * 查询意见反馈列表
     */
    @PreAuthorize("@ss.hasPermi('system:suggest:list')")
    @GetMapping("/list")
    public TableDataInfo list(TgxsUserSuggest tgxsUserSuggest)
    {
        startPage();
        List<TgxsUserSuggest> list = tgxsUserSuggestService.selectTgxsUserSuggestList(tgxsUserSuggest);
        return getDataTable(list);
    }

    /**
     * 导出意见反馈列表
     */
    @PreAuthorize("@ss.hasPermi('system:suggest:export')")
    @Log(title = "意见反馈", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TgxsUserSuggest tgxsUserSuggest)
    {
        List<TgxsUserSuggest> list = tgxsUserSuggestService.selectTgxsUserSuggestList(tgxsUserSuggest);
        ExcelUtil<TgxsUserSuggest> util = new ExcelUtil<TgxsUserSuggest>(TgxsUserSuggest.class);
        return util.exportExcel(list, "suggest");
    }

    /**
     * 获取意见反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:suggest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tgxsUserSuggestService.selectTgxsUserSuggestById(id));
    }

    /**
     * 新增意见反馈
     */
    @PreAuthorize("@ss.hasPermi('system:suggest:add')")
    @Log(title = "意见反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TgxsUserSuggest tgxsUserSuggest)
    {
        return toAjax(tgxsUserSuggestService.insertTgxsUserSuggest(tgxsUserSuggest));
    }

    /**
     * 修改意见反馈
     */
    @PreAuthorize("@ss.hasPermi('system:suggest:edit')")
    @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TgxsUserSuggest tgxsUserSuggest)
    {
        return toAjax(tgxsUserSuggestService.updateTgxsUserSuggest(tgxsUserSuggest));
    }

    /**
     * 删除意见反馈
     */
    @PreAuthorize("@ss.hasPermi('system:suggest:remove')")
    @Log(title = "意见反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tgxsUserSuggestService.deleteTgxsUserSuggestByIds(ids));
    }
}